package com.example.dao;

import com.example.domain.Candidate;
import com.example.domain.Department;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author luo
 */
@Mapper
public interface DepartmentDao {
    /**
     * 查询所有部门
     * @return
     */
    @Select("select * from department")
    public List<Department> selectAllDepart();

    /**
     * 按id查询部门
     * @param id
     * @return
     */
    @Select("select * from department where id=#{id}")
    public Department selectDepartmentById(Integer id);
    /**
     * 模糊查询
     * @param department
     * @return
     */
//    @Select("select * from department where name like #{name};")

    public List<Department> selectDepartmentByName(Department department);

    /**
     * 添加部门
     * @param department
     * @return
     */
    @Insert("insert into department (name, amount,content, director) values (#{name}, #{amount},#{content}, #{director})")
    public int addDepartment(Department department);

    /**
     * 更新部门
     *
     * @param department
     * @return
     */
    @Update("update department set name = #{name},amount=#{amount},content=#{content},director=#{director} where id=#{id};")
    public int updateDepartment(Department department);

    /**
     * 根据id删除部门
     * @param id
     * @return
     */
    @Delete("delete from department where id=#{id};")
    public int deleteDepartment(Integer id);
}
